<?php echo previous_link($section,$action,$go,$modal_window); 
if ($msg != "default") echo $msg_output; 

$query_edit = "SELECT * FROM project_deliverable WHERE id='$id'";
$edit = mysql_query($query_edit, $connection) or die(mysql_error());
$row_edit = mysql_fetch_assoc($edit);

$query_modules = "SELECT * FROM modules WHERE cid='$cid' ORDER BY mid ASC";
$modules = mysql_query($query_modules, $connection) or die(mysql_error());
$row_modules = mysql_fetch_assoc($modules);
$totalRows_modules = mysql_num_rows($modules);

if ($action != "confirm") {
if ($totalRows_pd > 0) { ?>
<?php //if ($totalRows_modules > $totalRows_pd) { ?>
<!--
<div class="info">
There are <?php // echo $totalRows_modules; ?> modules in this course and <?php  // echo $totalRows_pd; ?> project deliverables defined. Ideally, there should be at least one project deliverable in each module.
</div>
-->
<?php // } ?>
<!--
<p><span class="icon"><img src="images/monitor.png" border="0" align="absmiddle" /></span><a href="#thusfar">View the Deliverables Entered Thus Far</a></p>
-->
<?php if ($go == "confirm") { ?>
<p><span class="icon"><img src="images/arrow_left.png" border="0" align="absmiddle" /></span><a href="index.php?section=proposal_reveiw&amp;cid=<?php echo $cid; ?>&amp;modal_window=<?php $modal_window; ?>">Return to Step 5: Review the Completed Proposal</a></p>
<?php } elseif (($view != "proposal_detail") && ($modal_window == "false")) { ?>
<p>If you are finished entering project deliverables, <a href="index.php?section=clo&amp;action=view&amp;cid=<?php echo $cid; ?>">go to Step 4: Define Learning Outcomes</a>.</p>
<?php } 
}
if (($msg != "4") && ($msg !="5")) {
?>
<p>Each module in the course should feature at least one assignment that is a project deliverable. The goal of deliverables is to "chunk" the project into manageable sections relating to the corresponding module's content.</p>
<div class="stacked">
<span class="icon"><img src="images/disk.png" border="0" align="absmiddle" /></span><input id="Submit" name="Submit" type="submit" class="save_progress_form" value="<?php if (($action == "edit") || ($go == "missing")) echo "Update"; else echo "Save"; ?>">
</div>
<table class="dataTable">
<tr style="background-color: <?php echo $color1; ?>">
	<td class="dataLabel">Applies to:</td>
    <td class="dataLabel">
    <select name="mid" id="mid">
    	<option value="" ></option>
        <?php do { ?>
        <option value="<?php echo $row_modules['mid']; ?>"<?php if (((($action == "edit") || ($go == "missing")) || ($view == "proposal_detail")) && ($row_edit['mid'] == $row_modules['mid'])) echo " SELECTED"; ?>><?php echo "Module ".$row_modules['mid']; ?></option>
        <?php } while ($row_modules = mysql_fetch_assoc($modules)); ?>
      </select>
    </td>
    <td class="data help_text">&nbsp;</td>
</tr>
<tr style="background-color: <?php echo $color2; ?>">
  <td class="dataLabel">Name of Deliverable:</td>
  <td class="dataLabel"><input name="pd_name" type="text" size="50" value="<?php if (($action == "edit") || ($go == "missing")|| ($view == "proposal_detail")) echo $row_edit['pd_name']; ?>" /></td>
  <td class="data help_text">Provide a unique name for the deliverable.</td>
</tr>
<tr style="background-color: <?php echo $color1; ?>">
  <td class="dataLabel">Deliverable Number:</td>
  <td class="dataLabel">
  <select name="del_num" id="del_num">
    	<option value="" ></option>
    	<option value="01" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "1")) echo "SELECTED"; ?>>1</option>
        <option value="02" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "2")) echo "SELECTED"; ?> >2</option>
        <option value="03" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "3")) echo "SELECTED"; ?> >3</option>
        <option value="04" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "4")) echo "SELECTED"; ?> >4</option>
        <option value="05" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "5")) echo "SELECTED"; ?> >5</option>
        <option value="06" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "6")) echo "SELECTED"; ?> >6</option>
        <option value="07" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "7")) echo "SELECTED"; ?> >7</option>
        <option value="08" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "8")) echo "SELECTED"; ?> >8</option>
        <option value="09" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "9")) echo "SELECTED"; ?> >9</option>
        <option value="10" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "10")) echo "SELECTED"; ?> >10</option>
        <option value="01" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "11")) echo "SELECTED"; ?>>11</option>
        <option value="02" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "12")) echo "SELECTED"; ?> >12</option>
        <option value="03" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "13")) echo "SELECTED"; ?> >13</option>
        <option value="04" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "14")) echo "SELECTED"; ?> >14</option>
        <option value="05" <?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['del_num'] == "15")) echo "SELECTED"; ?> >15</option>
    </select>
  </td>
  <td class="data help_text">Provide a unique deliverable number.</td>
</tr>
<tr style="background-color: <?php echo $color2; ?>">
  <td colspan="3" class="dataLabel">Describe the key deliverable for the project assignment in this module.</td>
  </tr>
<tr style="background-color: <?php echo $color2; ?>">
	<td colspan="2" class="dataLabel"><textarea name="pd_desc1" cols="60" rows="15" class="mceNoEditor"><?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) echo $row_edit['pd_desc1']; ?></textarea></td>
    <td class="data help_text">&nbsp;</td>
</tr>
<tr style="background-color: <?php echo $color1; ?>">
  <td colspan="3" class="dataLabel">What do students need to know in order to complete the project assignment in this module? </td>
  </tr>
<tr style="background-color: <?php echo $color1; ?>">
	<td colspan="2" class="dataLabel"><textarea name="pd_desc2" cols="60" rows="15" class="mceNoEditor"><?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) echo $row_edit['pd_desc2']; ?></textarea></td>
    <td class="data help_text">&nbsp;</td>
</tr>
<tr style="background-color: <?php echo $color2; ?>">
  <td colspan="3" class="dataLabel">What information will be covered in the themes to help students complete the project assignment in this module? </td>
  </tr>
<tr style="background-color: <?php echo $color2; ?>">
	<td colspan="2" class="dataLabel"><textarea name="pd_desc3" cols="60" rows="15" class="mceNoEditor"><?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) echo $row_edit['pd_desc3']; ?></textarea></td>
    <td class="data help_text"><p>The major focus of this module is on [should align with the key project deliverable].  More specifically, students will learn about/or how to...</p></td>
</tr>
<tr style="background-color: <?php echo $color1; ?>">
  <td colspan="3" class="dataLabel">What information will be covered in the readings to help students complete the project assignment in this module?</td>
  </tr>
<tr style="background-color: <?php echo $color1; ?>">
	<td colspan="2" class="dataLabel"><textarea name="pd_desc4" cols="60" rows="15" class="mceNoEditor"><?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) echo $row_edit['pd_desc4']; ?></textarea></td>
    <td class="data help_text">&nbsp;</td>
</tr>
<tr style="background-color: <?php echo $color2; ?>">
  <td colspan="3" class="dataLabel">What will students be discussing in the Forum?</td>
  </tr>
<tr style="background-color: <?php echo $color2; ?>">
	<td colspan="2" class="dataLabel"><textarea name="pd_desc5" cols="60" rows="15" class="mceNoEditor"><?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) echo $row_edit['pd_desc5']; ?></textarea></td>
    <td class="data help_text">&nbsp;</td>
</tr>
</table>
<div class="stacked">
<span class="icon"><img src="images/disk.png" border="0" align="absmiddle" /></span><input id="Submit" name="Submit" type="submit" class="save_progress_form" value="<?php if (($action == "edit") || ($go == "missing")) echo "Update"; else echo "Save"; ?>">
</div>

<input name="vid" type="hidden" value="<?php if ($action == "add") echo "1"; elseif ((($action == "edit") || ($go == "missing")) && ($vid != "default")) echo ($row_edit['vid']); else echo ($row_edit['vid'] + 1); ?>" />
<?php } 
}
//elseif ($modal_window == "false") echo "";
if ($action == "confirm") { 
?>
<h2>Confirm</h2>
<p>Is this projec deliverable description acceptable?</p>
<div class="stacked"><span class="icon"><img src="images/page_add.png" border="0" align="absmiddle" /></span><a href="index.php?section=proj_deliv&amp;action=add&amp;cid=<?php echo $cid; ?>&amp;modal_window=<?php echo $modal_window; ?>">Yes, and I wish to add another project deliverable</a></div>
<div class="stacked"><span class="icon"><img src="images/tick.png" border="0" align="absmiddle" /></span>
<a href="javascript:confirmation('index.php?section=clo&amp;action=view&amp;cid=<?php echo $row_courses['id']; ?>&amp;modal_window=<?php echo $modal_window; ?>','','','Are you sure you are finished adding project deliverables?')">Yes, and I am finished adding project deliverables</a>
</div>
<div class="stacked"><span class="icon"><img src="images/exclamation.png" border="0" align="absmiddle" /></span><a href="index.php?section=proj_deliv&amp;action=edit&amp;go=no&amp;cid=<?php echo $cid; ?>&amp;vid=<?php echo $vid; ?>&amp;id=<?php echo $row_edit['id']; ?>&amp;modal_window=<?php echo $modal_window; ?>">No, further editing is required</a></div>
<table class="dataTable">
<tr style="background-color: <?php echo $color1; ?>">
	<td class="dataLabel">Applies To</td>
    <td class="data">Module <?php echo $row_edit['mid']; ?></td>
</tr>
<tr style="background-color: <?php echo $color2; ?>">
	<td class="dataLabel">Deliverable Number</td>
    <td class="data"><?php echo $row_edit['del_num']; ?></td>
</tr>
<tr style="background-color: <?php echo $color1; ?>">
	<td class="dataLabel">Deliverable Name</td>
    <td class="data"><?php echo $row_edit['pd_name']; ?></td>
</tr>
<tr style="background-color: <?php echo $color2; ?>">
	<td class="dataLabel">Weekly Project Deliverable</td>
    <td class="data"><?php echo $row_edit['pd_desc1']; ?></td>
</tr>
<tr style="background-color: <?php echo $color1; ?>">  
    <td class="dataLabel">What Students Need to Know</td>
    <td class="data"><?php echo $row_edit['pd_desc2']; ?></td>
</tr>
<tr style="background-color: <?php echo $color2; ?>">
    <td class="dataLabel">Information Covered in Themes</td>
    <td class="data"><?php echo $row_edit['pd_desc3']; ?></td>
</tr>
<tr style="background-color: <?php echo $color1; ?>">
    <td class="dataLabel">Information Covered in Readings</td>
    <td class="data"><?php echo $row_edit['pd_desc4']; ?></td>
</tr>
<tr style="background-color: <?php echo $color2; ?>">
    <td class="dataLabel">Topics Discussed in Forum</td>
    <td class="data"><?php echo $row_edit['pd_desc5']; ?></td>
</tr>
</table>
<?php } 
$query_cd = "SELECT * FROM project_deliverable WHERE cid='$cid' ORDER BY mid,del_num ASC";
$cd = mysql_query($query_cd, $connection) or die(mysql_error());
$row_cd = mysql_fetch_assoc($cd);
$totalRows_cd = mysql_num_rows($cd);
if (($totalRows_cd > 0) && ($msg == "default") && (($view != "proposal_detail") && ($go != "missing"))) { 
?>
<a name="thusfar"></a>
<h2>Deliverables Entered Thus Far</h2>
<table class="dataTable">
<tr>
	<th width="10%" nowrap="nowrap">Applies To</th>
    <th>Deliverable</th>
</tr>
<?php do { ?>
<tr style="background-color: <?php echo $color; ?>">
	<td>Module <?php echo $row_cd['mid']; ?></td>
    <td class="data">Deliverable <?php echo $row_cd['del_num']; ?> - <?php echo $row_cd['pd_name']; ?></td>
</tr>
<?php if ($color == $color1) { $color = $color2; } else { $color = $color1; } ?>
<?php } while ($row_cd = mysql_fetch_assoc($cd)); ?>
</table>
<?php } ?>